<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除用户</title>
</head>
<body>
    <%
        String id  =request.getParameter("id");
        Connection connection=null;
        PreparedStatement statement=null;

        String sql="DELETE from t_users where id=?";

        Class.forName("com.mysql.jdbc.Driver");

        connection= DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/sctu_javaweb_2018?useUnicode=true&characterEncoding=UTF-8",
                "root",
                "123456"
        );
        statement=connection.prepareStatement(sql);

        statement.setString(1, id);
        int result=statement.executeUpdate();
        String msg="删除失败！";
        if (result==1){
            msg="删除成功！";
        }

        statement.close();
        connection.close();

    %>
    <script>window.alert('<%=msg%>');</script>
    <%
        response.setHeader("Refresh","1;url=userList.jsp");
    %>
</body>
<%@include file="footer.jsp" %>
</html>
